{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 第五次练习"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "+ 请务必交到exer5文件夹下，**谢绝交到master下**\n",
    "+ 请不要改动任何文件，拜托\n",
    "+ 请在11月7日前提交。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "请写一下姓名和学号：\n",
    "+ 姓名  龙怡敏\n",
    "+ 学号  0163091"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目一、贫困户模型\n",
    "+ 创建一个类，包含贫困户的义务教育保障、住房安全、饮水安全、肉蛋奶豆的四个属性\n",
    "+ 包含一个是否贫困的预测，如果四个属性有两个以上没有保障（>2)则输出为贫困户\n",
    "+ 对贫困户，采取相应措施（输入参数）对其进行帮扶，使其脱贫\n",
    "+ 至少生成三个实例\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "False\n",
      "False\n",
      "False\n",
      "False\n",
      "该住户是贫困户\n",
      "因为贫困，采用了教育帮扶，并已完成\n",
      "因为贫困，采用了房屋安全帮扶，并已完成\n",
      "现在已经脱离贫困\n",
      "True\n",
      "False\n",
      "False\n",
      "False\n",
      "该住户是贫困户\n",
      "因为贫困，采用了房屋安全帮扶，并已完成\n",
      "现在已经脱离贫困\n",
      "True\n",
      "False\n",
      "False\n",
      "True\n",
      "该住户不是贫困户\n",
      "现在已经脱离贫困\n",
      "因为贫困，采用了房屋安全帮扶，并已完成\n",
      "现在已经脱离贫困\n"
     ]
    }
   ],
   "source": [
    "class poverty(object):\n",
    "    sum = 0\n",
    "    \n",
    "    def __init__(self, x1, x2, x3, x4):\n",
    "        self.edu = x1\n",
    "        self.house = x2\n",
    "        self.water = x3\n",
    "        self.protein = x4\n",
    "\n",
    "    def prediction_poverty(self):\n",
    "        print(self.edu)\n",
    "        print(self.house)\n",
    "        print(self.water)\n",
    "        print(self.protein)\n",
    "        if self.edu == False:\n",
    "            self.sum += 1\n",
    "        else:\n",
    "            self.sum += 0\n",
    "\n",
    "        if self.house == False:\n",
    "            self.sum += 1\n",
    "        else:\n",
    "            self.sum += 0\n",
    "\n",
    "        if self.water == False:\n",
    "            self.sum += 1\n",
    "        else:\n",
    "            self.sum += 0\n",
    "\n",
    "        if self.protein == False:\n",
    "            self.sum += 1\n",
    "        else:\n",
    "            self.sum += 0\n",
    "\n",
    "        if self.sum > 2:\n",
    "            print(\"该住户是贫困户\")\n",
    "        else:\n",
    "            print(\"该住户不是贫困户\")\n",
    "\n",
    "    def improve_edu(self):\n",
    "            if self.edu == False:\n",
    "                self.sum = self.sum - 1 \n",
    "                print(\"因为贫困，采用了教育帮扶，并已完成\")\n",
    "            if self.sum <= 2:\n",
    "                print(\"现在已经脱离贫困\")\n",
    "            \n",
    "    def improve_house(self):\n",
    "            if self.house == False:\n",
    "                self.sum = self.sum - 1\n",
    "                print(\"因为贫困，采用了房屋安全帮扶，并已完成\")\n",
    "            if self.sum <= 2:\n",
    "                print(\"现在已经脱离贫困\")\n",
    "\n",
    "yixieren = []\n",
    "yixieren.append(poverty(False, False, False, False))\n",
    "yixieren.append(poverty(True, False, False, False))\n",
    "yixieren.append(poverty(True, False, False, True))\n",
    "for index, man in enumerate(yixieren):\n",
    "    man.prediction_poverty()\n",
    "    man.improve_edu()\n",
    "    man.improve_house()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目二: 学生信息\n",
    "+ 创建一个类，包含姓名、分数、睡眠时间三个属性\n",
    "+ 包含一个胖瘦的预测，如果分数>90，且睡眠时间少于6小时，输出“BMI可能偏大”，否则输出“体重正常”\n",
    "+ 为使得标准（90分、6小时）可以调整，标准应设为输入的参数\n",
    "+ 至少生成三个实例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "体重正常\n",
      "体重正常\n",
      "BMI可能偏大\n"
     ]
    }
   ],
   "source": [
    "class students():\n",
    "    def __init__(self,x1,x2,x3):\n",
    "        self.name = x1\n",
    "        self.score = x2\n",
    "        self.sleepytime = x3\n",
    "        \n",
    "    def weight(self,score = 90,sleepytime = 6):\n",
    "        if self.score > score and self.sleepytime < sleepytime:\n",
    "            print(\"BMI可能偏大\")\n",
    "        else:\n",
    "            print(\"体重正常\")\n",
    "            \n",
    "\n",
    "\n",
    "            \n",
    "stu_1 = students(\"龙怡敏\", 85, 5 )\n",
    "stu_1.weight(score = 80, sleepytime = 4)\n",
    "stu_2 = students(\"龙二敏\", 80, 7 )\n",
    "stu_2.weight(score = 100, sleepytime = 6)\n",
    "stu_3 = students(\"龙三敏\", 100, 5 )\n",
    "stu_3.weight(90,6)\n",
    "     "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目三：“跑步社”成员类\n",
    "+ 创建一个“跑步社”成员类，以学生信息类为父类\n",
    "+ 添加一个属性为跑步\n",
    "+ 如果跑步时间大于30分钟，如果之前预测为“BMI可能偏大”，则输出为“趋向正常”\n",
    "+ 至少生成三个实例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "体重正常\n",
      "体重正常\n",
      "BMI可能偏大\n"
     ]
    }
   ],
   "source": [
    "class member(students):\n",
    "    def __init__(self,name,score,sleepytime,run):\n",
    "        super().__init__(name,score, sleepytime)                      \n",
    "        self.run = run\n",
    "    def weight(self,score ,sleepytime,run):\n",
    "        if self.score > score and self.sleepytime < sleepytime and self.run < run:\n",
    "            print(\"BMI可能偏大\")\n",
    "        else:\n",
    "            print(\"体重正常\")\n",
    "       \n",
    "            \n",
    "            \n",
    "\n",
    "stu_3 = member(\"龙三敏\", 100, 5,40)\n",
    "stu_3.weight(90,6,30)\n",
    "stu_4 = member(\"龙四敏\", 120, 4,60)\n",
    "stu_4.weight(100,5,30)\n",
    "stu_5 = member(\"龙五敏\", 100, 2,10)\n",
    "stu_5.weight(90,5,30)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
